using System;
using System.Collections.Generic;
using System.Collections;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.Content;

namespace MCGameEngine.Text_Layer
{
    class TextLayer : Microsoft.Xna.Framework.GameComponent
    {
        private int index = 0;
        private SpriteFont default_font;
        private Dictionary<string, Text_Layer.Label> labels;
       
        public TextLayer(MyGame game): base(game)
        {
            default_font = game.Content.Load<SpriteFont>("Arial");
            labels = new Dictionary<string,Text_Layer.Label>();
        }

        public override void Initialize()
        {
            base.Initialize();
        }

        public void Add(Label lbl)
        {
            labels.Add("unnamed" + index, lbl);
            index++;
        }

        public void Add(Label lbl, string name)
        {
            labels.Add(name, lbl);
        }

        public Text_Layer.Label Label(string name)
        {
            return labels[name];
        }

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
        }

        public void Draw()
        {
            foreach (Text_Layer.Label lbl in labels.Values)
            {
                if (lbl.visible)
                {
                    ((MyGame)this.Game).spriteBatch.DrawString(lbl.font, lbl.text, lbl.position, lbl.color);
                }
            }
        }
    }
}